<template>
  <V-CommonHeaderLeft>
    <div class="ware">
      <Navigation :msg="navMsg"></Navigation>
      <div class="ware-table">
        <el-table ref="multipleTable"
                  :data="stock"
                  :height="tableHeight"
                  class="table-class">
          <el-table-column type="index"
                           min-width="5%"
                           label="序号"></el-table-column>
          <el-table-column prop="orderId"
                           label="单号"
                           min-width="11.25%"
                           sortable>
            <template slot-scope="scope">
              <span :title="scope.row.orderId"
                    @click="toDetailsPage()">{{ scope.row.orderId }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="from"
                           min-width="11.25%"
                           label="客户供应商">
            <template slot-scope="scope">
              <span :class="scope.row.from.type == '客户' ? 'order-k' : 'order-g'">{{ scope.row.from.name }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="outType"
                           min-width="11.25%"
                           label="入库类型">
            <template slot-scope="scope">
              <span>{{ scope.row.outType }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="outWarehouse"
                           min-width="11.25%"
                           label="入库仓库">
            <template slot-scope="scope">
              <span :title="scope.row.outWarehouse">{{ scope.row.outWarehouse }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="orderStatus"
                           min-width="11.25%"
                           label="单据状态">
            <template slot-scope="scope">
              <span :class="(scope.row.orderStatus == '已完成' ? '' : 'not-status')">{{ scope.row.orderStatus }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="outEstimated"
                           min-width="11.25%"
                           label="预计入库">
            <template slot-scope="scope">
              <span :title="scope.row.outEstimated">{{ scope.row.outEstimated }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="orderPerson"
                           min-width="11.25%"
                           label="制单人">
            <template slot-scope="scope">
              <span :title="scope.row.orderPerson">{{ scope.row.orderPerson }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="submitTime"
                           min-width="11.25%"
                           label="提交时间"
                           sortable>
            <template slot-scope="scope">
              <span :title="scope.row.submitTime">{{ scope.row.submitTime }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="remarks"
                           min-width="5%"
                           label="备注">
            <template slot-scope="scope">
              <span :title="scope.row.remarks">{{ scope.row.remarks }}</span>
              <div class="hover-box">
                <router-link to="#">编辑</router-link>
                <router-link to="#">删除</router-link>
              </div>
            </template>
          </el-table-column>
        </el-table>
        <Paging :msg="pageMsg.length"
                ref="fn"
                @pageNum="getPageNum"
                @pageId="getPageId"></Paging>
      </div>
    </div>
  </V-CommonHeaderLeft>
</template>
<script>
import VCommonHeaderLeft from '@/components/common/vCommonHeaderLeft/VCommonHeaderLeft'
import Navigation from '@/components/common/navigation/Navigation'
import Paging from '@/components/common/paging/Paging'
export default {
  data () {
    return {
      tableHeight: '',
      pageNum: 15, // 每页默认显示15条,
      pageId: 1, // 页面id
      judgeStatus: false, // 排序状态
      navMsg: [
        {
          name: '仓库',
          path: '/outStock'
        },
        {
          name: '商品入库',
          path: ''
        }
      ],
      stock: [],
      pageMsg: [
        {
          id: 1,
          orderId: 'CK-20190412-0003',
          from: {
            type: '客户',
            name: '深圳宝能太古'
          },
          outType: '其他入库',
          outWarehouse: '深圳仓',
          orderStatus: '已完成',
          outEstimated: '2019-04-22',
          orderPerson: '陈素然',
          submitTime: '2019-04-22',
          eemarks: ''
        },
        {
          id: 2,
          orderId: 'CK-20190423-0043',
          from: {
            type: '客户',
            name: '深圳宝能太古'
          },
          outType: '其他入库',
          outWarehouse: '深圳仓',
          orderStatus: '已完成',
          outEstimated: '2019-04-22',
          orderPerson: '陈素然',
          submitTime: '2019-04-22',
          eemarks: ''
        },
        {
          id: 3,
          orderId: 'CK-20100422-023',
          from: {
            type: '供应商',
            name: '深圳宝能太古'
          },
          outType: '其他入库',
          outWarehouse: '深圳仓',
          orderStatus: '未完成',
          outEstimated: '2019-04-22',
          orderPerson: '陈素然',
          submitTime: '2019-04-22',
          eemarks: ''
        },
        {
          id: 4,
          orderId: 'CK-20200422-0563',
          from: {
            type: '客户',
            name: '深圳宝能太古'
          },
          outType: '销售出库',
          outWarehouse: '深圳仓',
          orderStatus: '已完成',
          outEstimated: '2019-04-22',
          orderPerson: '陈素然',
          submitTime: '2019-04-23',
          eemarks: ''
        },
        {
          id: 5,
          orderId: 'CK-21190422-0073',
          from: {
            type: '客户',
            name: '深圳宝能太古'
          },
          outType: '销售出库',
          outWarehouse: '深圳仓',
          orderStatus: '已完成',
          outEstimated: '2019-04-22',
          orderPerson: '陈素然',
          submitTime: '2019-04-22',
          eemarks: ''
        },
        {
          id: 6,
          orderId: 'CK-20190422-0031',
          from: {
            type: '客户',
            name: '深圳宝能太古'
          },
          outType: '销售出库',
          outWarehouse: '深圳仓',
          orderStatus: '已完成',
          outEstimated: '2019-04-22',
          orderPerson: '陈素然',
          submitTime: '2019-05-22',
          eemarks: ''
        },
        {
          id: 7,
          orderId: 'CK-20190422-0603',
          from: {
            type: '客户',
            name: '深圳宝能太古'
          },
          outType: '销售出库',
          outWarehouse: '深圳仓',
          orderStatus: '已完成',
          outEstimated: '2019-04-22',
          orderPerson: '陈素然',
          submitTime: '2019-04-23',
          eemarks: ''
        },
        {
          id: 8,
          orderId: 'CK-20190422-0803',
          from: {
            type: '客户',
            name: '深圳宝能太古'
          },
          outType: '销售出库',
          outWarehouse: '深圳仓',
          orderStatus: '已完成',
          outEstimated: '2019-04-22',
          orderPerson: '陈素然',
          submitTime: '2019-04-22',
          eemarks: ''
        },
        {
          id: 9,
          orderId: 'CK-20190422-1115',
          from: {
            type: '客户',
            name: '深圳宝能太古'
          },
          outType: '销售出库',
          outWarehouse: '深圳仓',
          orderStatus: '已完成',
          outEstimated: '2019-04-22',
          orderPerson: '陈素然',
          submitTime: '2019-04-22',
          eemarks: ''
        },
        {
          id: 10,
          orderId: 'CK-20190422-0033',
          from: {
            type: '客户',
            name: '深圳宝能太古'
          },
          outType: '销售出库',
          outWarehouse: '深圳仓',
          orderStatus: '已完成',
          outEstimated: '2019-04-22',
          orderPerson: '陈素然',
          submitTime: '2019-04-22',
          eemarks: ''
        },
        {
          id: 11,
          orderId: 'CK-20190422-0033',
          from: {
            type: '客户',
            name: '深圳宝能太古'
          },
          outType: '销售出库',
          outWarehouse: '深圳仓',
          orderStatus: '已完成',
          outEstimated: '2019-04-22',
          orderPerson: '寒酥',
          submitTime: '2019-04-22',
          eemarks: ''
        },
        {
          id: 12,
          orderId: 'CK-20190422-0033',
          from: {
            type: '客户',
            name: '深圳宝能太古'
          },
          outType: '销售出库',
          outWarehouse: '深圳仓',
          orderStatus: '已完成',
          outEstimated: '2019-04-22',
          orderPerson: '寒酥',
          submitTime: '2019-04-22',
          eemarks: ''
        },
        {
          id: 13,
          orderId: 'CK-20190422-0033',
          from: {
            type: '客户',
            name: '深圳宝能太古'
          },
          outType: '销售出库',
          outWarehouse: '深圳仓',
          orderStatus: '已完成',
          outEstimated: '2019-04-22',
          orderPerson: '寒酥',
          submitTime: '2019-04-22',
          eemarks: ''
        },
        {
          id: 14,
          orderId: 'CK-20190422-0033',
          from: {
            type: '客户',
            name: '深圳宝能太古'
          },
          outType: '销售出库',
          outWarehouse: '深圳仓',
          orderStatus: '已完成',
          outEstimated: '2019-04-22',
          orderPerson: '寒酥',
          submitTime: '2019-04-22',
          eemarks: ''
        }
      ]
    }
  },
  components: {
    Navigation,
    Paging,
    VCommonHeaderLeft
  },
  created () {
    this.stock = this.pageMsg
    this.getHight()
    window.addEventListener('resize', this.getHight)
  },
  destroyed () {
    window.removeEventListener('resize', this.getHight)
  },
  methods: {
    getHight () {
      this.tableHeight = window.innerHeight - 162 + 'px'
    },
    getPageId (id = 1) {
      this.pageId = id
      this.stock = this.$refs.fn.sliceArray(this.pageMsg, this.pageNum, id - 1)
    },
    getPageNum (num) {
      // console.log(num)
      this.pageNum = num
      this.getPageId()
      // console.log(this.stock)
    },
    toDetailsPage () {
      this.$router.push({
        path: '/inStockDetails'
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.ware {
  width: 100%;
  margin-right: 10px;
  overflow: hidden;
  font-size: 12px;
  background-color: #ffffff;
  @mixin over-ellipsis {
    width: 100%;
    line-height: 20px;
    display: -webkit-box;
    overflow: hidden;
    white-space: normal !important;
    text-overflow: ellipsis;
    word-wrap: break-word;
    word-break: break-all;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .ware-table {
    width: 100%;
    overflow: hidden;
    @mixin el-common($el-color, $el-height, $el-class) {
      padding: 0;
      color: $el-color;
      height: $el-height;
      line-height: $el-height;
      &:first-child {
        text-align: center;
        span {
          width: 16px;
          height: 16px;
        }
      }
      &:not(:first-child) {
        #{$el-class} {
          @include over-ellipsis;
        }
      }
    }
    /deep/ .el-table__body-wrapper {
      overflow-y: hidden;
      &:hover {
        overflow-y: overlay;
      }
      &::-webkit-scrollbar {
        width: 8px;
        height: 50%;
      }
      &::-webkit-scrollbar-thumb {
        border-radius: 10px;
        background-color: rgba(0, 0, 0, 0.2);
      }
      &::-webkit-scrollbar-track {
        border-radius: 0;
        background-color: rgba(0, 0, 0, 0.1);
      }
    }
    /deep/ .table-class {
      font-size: 12px;
      padding: 0;
      tr {
        position: relative;
        &:hover {
          .hover-box {
            display: flex;
          }
        }
        td {
          @include el-common(
            $el-color: #333,
            $el-height: 40px,
            $el-class: "span"
          );
          &:nth-child(2) {
            &:hover {
              cursor: pointer;
              color: #20bdeb;
            }
          }
          .hover-box {
            display: none;
            position: absolute;
            top: 0;
            right: 0;
            height: 100%;
            border: 0 none;
            background-color: #a3bbd4;
            box-shadow: none;
            align-items: center;
            text-align: center;
            cursor: pointer;
            white-space: normal;
            word-break: normal;
            padding: 0 12px;
            z-index: 2;
            a {
              display: flex;
              width: 30px;
              padding: 0 12px;
              color: #ffffff;
              height: 100%;
              justify-content: center;
              align-items: center;
              font-size: 12px;
            }
          }
        }
        th {
          font-weight: normal;
          background-color: #fcfcfc;
          @include el-common(
            $el-color: #666,
            $el-height: 50px,
            $el-class: ".cell"
          );
        }
        .order-k::before {
          content: "[客]";
          color: #65d142;
          margin-right: 4px;
        }
        .order-g::before {
          content: "[供]";
          color: #20ade5;
          margin-right: 4px;
        }
      }
      .not-status {
        color: #ff3838;
      }
    }
  }
}
</style>
